/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.app.entity;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author EduardoAlexis
 */
@Entity
@Table(name = "ingrediente")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Ingrediente.findAll", query = "SELECT i FROM Ingrediente i"),
    @NamedQuery(name = "Ingrediente.findByIdIngrediente", query = "SELECT i FROM Ingrediente i WHERE i.idIngrediente = :idIngrediente"),
    @NamedQuery(name = "Ingrediente.findByNombre", query = "SELECT i FROM Ingrediente i WHERE i.nombre = :nombre"),
    @NamedQuery(name = "Ingrediente.findByCosto", query = "SELECT i FROM Ingrediente i WHERE i.costo = :costo"),
    @NamedQuery(name = "Ingrediente.findByUMedida", query = "SELECT i FROM Ingrediente i WHERE i.uMedida = :uMedida"),
    @NamedQuery(name = "Ingrediente.findByUMedidaCompra", query = "SELECT i FROM Ingrediente i WHERE i.uMedidaCompra = :uMedidaCompra"),
    @NamedQuery(name = "Ingrediente.findByCurrentStock", query = "SELECT i FROM Ingrediente i WHERE i.currentStock = :currentStock"),
    @NamedQuery(name = "Ingrediente.findByStockMin", query = "SELECT i FROM Ingrediente i WHERE i.stockMin = :stockMin"),
    @NamedQuery(name = "Ingrediente.findByStockIdeal", query = "SELECT i FROM Ingrediente i WHERE i.stockIdeal = :stockIdeal"),
    @NamedQuery(name = "Ingrediente.findByConversionMedida", query = "SELECT i FROM Ingrediente i WHERE i.conversionMedida = :conversionMedida")})
public class Ingrediente implements Serializable {
    @Size(max = 50)
    @Column(name = "unidades")
    private String unidades;
    @Size(max = 100)
    @Column(name = "descripcion")
    private String descripcion;
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id_ingrediente")
    private Long idIngrediente;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "nombre")
    private String nombre;
    @Column(name = "costo")
    private BigInteger costo;
    @Size(max = 45)
    @Column(name = "u_medida")
    private String uMedida;
    @Size(max = 45)
    @Column(name = "u_medida_compra")
    private String uMedidaCompra;
    @Column(name = "current_stock")
    private BigInteger currentStock;
    @Column(name = "stock_min")
    private BigInteger stockMin;
    @Column(name = "stock_ideal")
    private BigInteger stockIdeal;
    @Column(name = "conversion_medida")
    private BigInteger conversionMedida;
    @JoinColumn(name = "id_estado", referencedColumnName = "id_estado")
    @ManyToOne(optional = false)
    private Estado idEstado;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idIngrediente")
    private List<Receta> recetaList;

    public Ingrediente() {
    }

    public Ingrediente(Long idIngrediente) {
        this.idIngrediente = idIngrediente;
    }

    public Ingrediente(Long idIngrediente, String nombre) {
        this.idIngrediente = idIngrediente;
        this.nombre = nombre;
    }

    public Long getIdIngrediente() {
        return idIngrediente;
    }

    public void setIdIngrediente(Long idIngrediente) {
        this.idIngrediente = idIngrediente;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public BigInteger getCosto() {
        return costo;
    }

    public void setCosto(BigInteger costo) {
        this.costo = costo;
    }

    public String getUMedida() {
        return uMedida;
    }

    public void setUMedida(String uMedida) {
        this.uMedida = uMedida;
    }

    public String getUMedidaCompra() {
        return uMedidaCompra;
    }

    public void setUMedidaCompra(String uMedidaCompra) {
        this.uMedidaCompra = uMedidaCompra;
    }

    public BigInteger getCurrentStock() {
        return currentStock;
    }

    public void setCurrentStock(BigInteger currentStock) {
        this.currentStock = currentStock;
    }

    public BigInteger getStockMin() {
        return stockMin;
    }

    public void setStockMin(BigInteger stockMin) {
        this.stockMin = stockMin;
    }

    public BigInteger getStockIdeal() {
        return stockIdeal;
    }

    public void setStockIdeal(BigInteger stockIdeal) {
        this.stockIdeal = stockIdeal;
    }

    public BigInteger getConversionMedida() {
        return conversionMedida;
    }

    public void setConversionMedida(BigInteger conversionMedida) {
        this.conversionMedida = conversionMedida;
    }

    public Estado getIdEstado() {
        return idEstado;
    }

    public void setIdEstado(Estado idEstado) {
        this.idEstado = idEstado;
    }

    @XmlTransient
    public List<Receta> getRecetaList() {
        return recetaList;
    }

    public void setRecetaList(List<Receta> recetaList) {
        this.recetaList = recetaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idIngrediente != null ? idIngrediente.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Ingrediente)) {
            return false;
        }
        Ingrediente other = (Ingrediente) object;
        if ((this.idIngrediente == null && other.idIngrediente != null) || (this.idIngrediente != null && !this.idIngrediente.equals(other.idIngrediente))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.app.entity.Ingrediente[ idIngrediente=" + idIngrediente + " ]";
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public String getUnidades() {
        return unidades;
    }

    public void setUnidades(String unidades) {
        this.unidades = unidades;
    }
    
}
